﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

namespace Utility.Config
{
    /// <summary>
    /// 读取WebConfig值
    /// </summary>
    public class ConfigHelper
    {
        /// <summary>
        /// 默认数据条数
        /// </summary>
        public static int DefaultPageSize = 10;
        /// <summary>
        /// 域名
        /// </summary>
        public static string WebDomain = string.Empty;
        /// <summary>
        /// 首页
        /// </summary>
        public static string WebHomeUrl = string.Empty;

        public static string WebHomeAddress_CMS = string.Empty;
        /// <summary>
        /// 支付宝异步通知
        /// </summary>
        public static string notify_url { get; set; }
        /// <summary>
        /// 微信异步通知
        /// </summary>
        public static string notify_url_wx { get; set; }
        /// <summary>
        /// 支付宝返回页面
        /// </summary>
        public static string return_url { get; set; }
        /// <summary>
        /// 支付内容
        /// </summary>
        public static string subject { get; set; }
        /// <summary>
        /// 初始化WebConfig文件中的项
        /// </summary>
        public static void SetConfig()
        {
            WebHomeUrl = GetConfigAppSetting("WebHomeAddress");
            WebHomeAddress_CMS = GetConfigAppSetting("WebHomeAddress_CMS");
            WebDomain = GetConfigAppSetting("WebDomain");
            DefaultPageSize = GetConfigAppSetting("DefaultPageSize").ToSafeInt();


            notify_url = GetConfigAppSetting("notify_url");

            return_url = GetConfigAppSetting("return_url");

            notify_url_wx = GetConfigAppSetting("notify_url_wx");

            subject = GetConfigAppSetting("subject");
        }
        public static string GetConfigAppSetting(string strName)
        {
            return ConfigurationManager.AppSettings[strName].ToSafeString();
        }
    }
}
